<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>多行文本居中</title>
  <style>
    .box1 {
      width: 300px;
      padding: 100px 0;
      text-align: center;
      background: #bbf;
    }

    .box2 {
      display: table;
      width: 300px;
      height: 500px;
      text-align: center;
      background: #bfa;
      margin-bottom: 50px;
    }

    .inner {
      display: table-cell;
      vertical-align: middle;
    }

    .link1 {
      padding: 30px 30px;
      background: #bbf;
    }
  </style>
</head>
<body>
  <h1>父元素不固定高度</h1>
  <div class="box1">
    <p>多行文本</p>
    <p>多行文本</p>
    <p>多行文本</p>
    <p>多行文本</p>
    <p>多行文本</p>
  </div>
  <h1>父元素固定高度</h1>
  <div class="box2">
    <div class="inner">
      <p>多行文本</p>
      <p>多行文本</p>
      <p>多行文本</p>
      <p>多行文本</p>
      <p>多行文本</p>
    </div>
  </div>
  <a href="#" class="link1">link1</a>
</body>
</html>
